package com.app.controller;


import com.app.entity.User;
import com.app.service.UserService;
import com.app.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zxy
 * @since 2021-03-23
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 修改密码
     * @return
     */
    @RequestMapping("/admin/updateAdmin")
    public Result updateAdmin(@RequestBody User user) {
        return userService.updateAdmin(user);
    }

    /**
     * 查询用户
     */
    @RequestMapping("/findAllUser")
    public Result findAllUser(@RequestParam("username") String username) {
        return userService.findAllUser(username);
    }

    //查询用户数量

    @RequestMapping("/findUserNumByAdmin")
    public Result findUserNumByAdmin(){
        return userService.findUserNumByAdmin();
    }
    //用户信息修改
    @RequestMapping("/updateUser")
    public Result updateUser(@RequestBody User user){
        return userService.updateUser(user);
    }
}

